# -*- coding: utf-8 -*-
"""
  @Time    : 2024/3/1 17:57
  @Author  : 
  @email   : 
  @File    : manage.py
"""

from extensions import scheduler
from task import worker


def persistent_containers_info():
    with scheduler.app.app_context():
        worker.persistent_containers_info()


def persistent_containers_info_single():
    with scheduler.app.app_context():
        worker.persistent_containers_info_single()


def domainname_to_hosts():
    with scheduler.app.app_context():
        worker.domainname_to_hosts()


def register_jobs():
    scheduler.add_job(
        func=persistent_containers_info,
        id='0',
        name='容器信息持久化任务',
        trigger='cron',
        second=8,
        minute=8,
        hour=18)
    scheduler.add_job(
        func=persistent_containers_info_single,
        id='1',
        name='单路容器信息持久化任务',
        trigger='cron',
        second=1,
        minute=1,
        hour=18)
    scheduler.add_job(
        func=domainname_to_hosts,
        id='2',
        name='添加hosts本地解析记录',
        trigger='interval',
        seconds=20)
